<?php
/**
 * @fileName:Component.php
 * @project: miaosang
 * @nameSpace:miaosang\yii2\bases
 * @Class Component
 * @author : 吐火青蛙
 * @user : 吐火青蛙
 * @date : 2021-08-18 01:54
 * @desc : Component
 * @Copyright (c)  2021,All Rights Reserved.
 */

namespace miaosang\yii2\bases;
use miaosang\yii2\traits\CreateObject;
use yii\base\Component as BaseComponent;
class Component extends BaseComponent
{
	private $_component =[];
	use CreateObject;

	/**
	 * @desc 增加组件
	 * @param  mixed  $object
	 * @return $this|mixed
	 * @throws \Exception
	 */
	public function addComponent(mixed $object):mixed{
		$component = $this->createObject($object);
		if (empty($this->_component)) {
			$this->_component = [];
		}
		array_push($this->_component,$component);
		return $this;
	}

	/**
	 * @desc 获取所有的Component
	 * @return array
	 */
	public function getComponent(){
		return $this->_component;
	}

}